package cn.serein.charging.order.quartz;


import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * 由于orderRepository 不在IOC容器当中，所以在DeviceCheckJob中无法注入   她是通过new的方式调用的
 * 可以通过applicationContext 来获取
 */

@Component
public class DeviceCheckJobUtils implements ApplicationContextAware {

    private static ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    public static <T> T getBean(String name,Class<T> clazz) {
        return applicationContext.getBean(name,clazz);
    }
}
